import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;

import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.list.ListCellRenderer;


public class MyListCellRenderer extends Container implements ListCellRenderer{

	BorderLayout layout;
	Label Message = new Label("");
	//TextArea  Message=new TextArea ("");
	public MyListCellRenderer() {
		setLayout(new BorderLayout());
		
		Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
		Message.getStyle().setBgTransparency(0);	
		
		cnt.addComponent(Message);
		
		addComponent(BorderLayout.CENTER, cnt);
		//addComponent(Message);
	}

	public Component getListCellRendererComponent(List arg0, Object arg1,
			int arg2, boolean arg3) {
		// TODO Auto-generated method stub
		TheMessage person = (TheMessage) arg1;
		Message.setText(person.getMessage());
		if(person.getId()==1)
		{
			Message.getStyle().setAlignment(LEFT);			
		}
		else
		{
			Message.getStyle().setAlignment(RIGHT);
		}
		return this;
	}

	public Component getListFocusComponent(List arg0) {
		// TODO Auto-generated method stub
		return null;
	}

}
